/////////////////////////////////////////////////////////////////////////////////
// TgcViewer-cpp
// 
// Author: Matias Leone
// 
/////////////////////////////////////////////////////////////////////////////////



#pragma once


//General Includes:
#include <string>
#include <vector>
using namespace std;

//Project Includes:
#include "TgcViewer/globals.h"
#include "TgcViewer/Math/Vector2.h"
#include "TgcViewer/Ui/Gui/TgcGuiItem.h"

//Forward declaration for "TgcViewer/GuiController.h"
namespace TgcViewer {class GuiController;}

namespace TgcViewer
{



/**
* 2D User interface manager. Tool to render UI widgets like checkboxes, comboboxes, etc.
*/
class TgcGui
{

public:

	/**
	* Type of event
	*/
	enum MessageType
	{
		MessageType_None,
		MessageType_Command
	};

	/**
	* Event generated by the GUI
	*/
	struct Message
	{
		MessageType type;
		string id;
	};


	TgcGui();
	TgcGui(const TgcGui&);
	~TgcGui();

	/**
	* Resets all gui values to default.
	* It removes and dispose all the items
	*/
	void reset();

	/**
	* Updates the the GUI states.
	* @return New event generated
	*/
	Message update();

	/**
	* Draws all the gui items
	*/
	void render();

	/**
	* Free resources
	*/
	void dispose();

	/**
	* Returns the item with the id specified
	*/
	TgcGuiItem* get(const string id) const;
	//TgcGuiItem* operator[] (const string id) const;

	/**
	* Adds a new item
	*/
	void add(TgcGuiItem* item);

	/**
	* Removes an existing item
	*/
	void remove(const string id);



	/**
	* {Internal}
	* Search an item placed in the specified location
	*/
	TgcGuiItem* getItemInPos(const Vector2 pos) const;

	/**
	* {Internal}
	* Returns the index of the item in guiItems, or -1 if it is not found
	*/
	int getItemIndex(const string id) const;

private:
	
public:

	/**
	* Widgets of the GUI
	*/
	vector<TgcGuiItem*> guiItems;

	/**
	* Current selected item
	*/
	TgcGuiItem* selectedItem;

	/**
	* Last item with mouse over
	*/
	TgcGuiItem* lastMouseOverItem;


	bool isMouseLeftDown;


private:

	
};




}